package com.rbcs.sharing.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

import com.systop.common.modules.security.user.model.User;
import com.systop.core.model.BaseModel;

/**
 * 费用分摊
 * @author Nice
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "sharing")
public class Sharing extends BaseModel {

	private Integer id;
	
	private String code;
	
	private Integer year;
	
	private User creater;
	
	private List<SharingItem> sharingItems = new ArrayList<SharingItem>();
	
	private Double amount;

	@Id
	@GeneratedValue(generator = "hibseq")
	@GenericGenerator(name = "hibseq", strategy = "hilo")
	@Column(name = "id", nullable = false)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Integer getYear() {
		return year;
	}

	public void setYear(Integer year) {
		this.year = year;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.EAGER)
	@JoinColumn(name = "creater_id")
	public User getCreater() {
		return creater;
	}

	public void setCreater(User creater) {
		this.creater = creater;
	}

	@OneToMany(cascade = {}, fetch = FetchType.LAZY, mappedBy = "sharing")
	public List<SharingItem> getSharingItems() {
		return sharingItems;
	}

	public void setSharingItems(List<SharingItem> sharingItems) {
		this.sharingItems = sharingItems;
	}

	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}
	
}
